package com.cjdes.recipes4u.dto;

import java.io.Serializable;
import java.util.List;

import ae.javax.xml.bind.annotation.XmlAccessorType;
import ae.javax.xml.bind.annotation.XmlAttribute;
import ae.javax.xml.bind.annotation.XmlElement;
import ae.javax.xml.bind.annotation.XmlRootElement;
import ae.javax.xml.bind.annotation.XmlAccessType;

@XmlRootElement(name = "recipe")
@XmlAccessorType(XmlAccessType.FIELD)
public class Recipe implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -3933619428940614162L;
	@XmlAttribute
	private String name;
	@XmlElement(name="ingredients")
	private List<Ingredient> ingredients;
	@XmlElement
	private String method;
	@XmlAttribute
	private String type;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Ingredient> getIngredients() {
		return ingredients;
	}

	public void setIngredients(List<Ingredient> ingredients) {
		this.ingredients = ingredients;
	}

	public String getMethod() {
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
	public String ingredientsToString(){
		StringBuilder builder = new StringBuilder();
		for (Ingredient i : ingredients) {
			builder.append(i.getWeight() + " " + i.getName() +"\n");
		}
		return builder.toString();
	}

}
